<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<spring:url value="/images/glyphicons_150_edit.png" var="edit"></spring:url>

<script src="${jsUrl}" type="text/javascript"></script>
<script>

function cambiaPagDati(page){
	
	document.getElementById("pagina").value=page;
	document.getElementById("ricercaAziendeForm").submit();
}

</script>
<div class="unit-row">
		<nav class="nav-tabs" style="width:1000px">
			<ul>
				<li><span>Ricerca Aziende</span></li>
				<li><a href="${flowExecutionUrl}&_eventId=nuova-azienda">Nuova Azienda</a></li>
				<li><a href="<c:url value="j_spring_security_logout" />">Logout</a></li>				
			</ul>
		</nav>
		<br />
		<div class="unit-100 unit-centered" style="width:800px">
			<h3 class="head-toc head-toc-start">Ricerca aziende</h3>
			<form:form id="ricercaAziendeForm" cssClass="forms forms-columnar"
				action="${flowExecutionUrl}" method="POST" commandName="ricercaAziendeForm" >
				<form:hidden path="searched"/>
				
				<fieldset title="Ricerca Aziende">
					<p class="forms-inline">
						<form:label path="query" cssErrorClass="error">Azienda da ricercare</form:label>
						<form:input path="query" cssClass="width-60" maxlength="50"
							cssErrorClass="input-error width-60" />
						<form:errors path="query" cssClass="error"></form:errors>
					</p>
					<p class="forms-inline">
						<form:hidden id="pagina" path="pagina"/>
						<form:hidden path="recordPerPagina" />
						<input type="hidden" name="_eventId" id="eventId" value="refreshAziende"> 
						<input type="reset" class="btn" value="Annulla"> 
						<input type="submit" id="cercaTraLeAziende" class="btn btn-round" value="Cerca tra le aziende" />
					</p>
				</fieldset>				
				
				<c:set var="aziendeList" value="${ricercaAziendeForm.aziende}" scope="session" />
				<c:if test="${not empty aziendeList}">
	 				<c:out value="${pagedAziendeBanner}" escapeXml="false"></c:out> 
					<table style="margin:auto;width:750px">
					<tr>
						<td>
							<table style="margin:auto;">
								<tr>
									<td style="width:125px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										Nome
									</td>	
									<td style="width:125px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										Sito web
									</td>
									<td style="width:125px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										Referente
									</td>
									<td style="width:125px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										Settore
									</td>		
									<td style="width:125px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										Citt&agrave;
									</td>							
									<td style="width:30px;border:0;text-align:center;padding-left:20px;padding-right:0px;"">
										&nbsp;
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colSpan="6" style="width:750px;padding-left:0px;padding-right:0px;">
							<div style="width:100%;overflow-y:scroll;height:200px;">
								<table style="text-align:left;margin:auto;">
									<c:forEach var="recordAziende" items="${aziendeList}" varStatus="aziende" begin="0" >
										<tr>
											<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
												&nbsp;<c:out value="${recordAziende.nome}"></c:out>
											</td>
											<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
												&nbsp;<c:out value="${recordAziende.sitoWeb}"></c:out>
											</td>
											<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
												&nbsp;<c:out value="${recordAziende.referente}"></c:out>
											</td>	
											<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
												&nbsp;<c:out value="${recordAziende.settore}"></c:out>
											</td>
											<td style="width:125px;text-align:center;padding-left:20px;padding-right:0px;">
												&nbsp;<span title="<c:out value='${recordAziende.indirizzoVia}'/>"><c:out value="${recordAziende.indirizzoCitta}"/></span>
											</td>	
											<td style="width:30px;text-align:center;">
												<a href="${flowExecutionUrl}&_eventId=dettaglioAzienda&idAzienda=${recordAziende.idAzienda}">
													<img alt="Visualizza azienda" src="${edit}" border="0">
												</a>	
											</td>				
										</tr>
									</c:forEach>	
								</table>
							</div>
						</td>
					</tr>
				</table>
			</c:if>
			
		</form:form>
	</div>
</div>